#ifndef REVERSELIST_H
#define REVERSELIST_H

#include "../core/LinkedList.h"

ListNode* reverseList(ListNode* list) {
    if (list == nullptr || list->next == nullptr) {
        return list;
    }

    ListNode* prev = nullptr;
    ListNode* current = list;
    ListNode* next = nullptr;

    while (current != nullptr) {
        next = current->next;
        current->next = prev;
        prev = current;
        current = next;
    }

    return prev;
}

#endif
